import request from '@/utils/request';

export async function fakeRegister(data) {
  return request({
    url: '/security/user',
    method: 'POST',
    data
  });
}

export async function fakeAccountLogin(data) {
  return request({
    url:'/login',
    method: 'POST',
    data
  });
}

export async function getFakeCaptcha(mobile) {
  return request(`/api/login/captcha?mobile=${mobile}`);
}
export function register(query) {
  return request({
    url: '/system/user',
    method: 'post',
    data: query
  });
}
/**
 * 修改用户密码
 * @param oldPassword
 * @param newPassword
 */
export function modifyPassword(oldPassword, newPassword) {
  return request({
    url: '/system/user/pass',
    method: 'put',
    data: {
      'oldPassword': oldPassword,
      'password': newPassword,
    }
  })

}
/**
 * 用户修改
 * @method userChange
 * @param {参数类型}
 * {
    "id":"a873f670-7451-11e8-89de-f48e38aab906"
    "username":"wy2",
    "password":"12345",
    "kgdRole":"ROOT",
    "info":"info",
    "cellphoneNumber":"",
    "actualName":"",
    "imageUrl":"",
    "email":""
 * }
 * @return {object} 返回值说明
 * {
    "retCode": "0",
    "message": "用户修改成功"
 * }
 */
export function userChange(query) {
  return request({
    url: '/system/role',
    method: 'put',
    data: query
  })
}

/**
 * 查询所有用户
 * @method allusers
 * @param {*} query
 * {
    page_id=0
    page_size=3
    direction=DESC
    properties=created_date,activated
 * }
 */
export function allusers(query) {
  return request({
    url: '/system/user/query',
    method: 'post',
    data:query
  })
}
/**
 * 修改用户密码
 * @param userId
 * @param newPassword
 */
export function resetPassword(userId,userName) {
  return request({
    url: '/system/user/reset',
    method: 'put',
    data: {
      'userId': userId,
      'username': userName
    }
  })

}
